package com.smartlink.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.smartlink.pojo.Setting;

public class SettingDaoImpl implements Dao<Integer, Setting> {
	private SessionFactory sessionFactory;
	private Session session;

	public Session getSession() {
		session = sessionFactory.getCurrentSession();
		return session;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	@Override
	public boolean insert(Setting v) {
		// TODO Auto-generated method stub
		getSession().save(v);
		return true;
	}

	@Override
	public boolean delete(Setting v) {
		// TODO Auto-generated method stub
		getSession().delete(v);
		return true;
	}

	@Override
	public boolean deleteById(Integer k) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean update(Setting v) {
		// TODO Auto-generated method stub
		getSession().update(v);
		return true;
	}

	@Override
	public Setting findById(Integer k) {
		// TODO Auto-generated method stub
		//String hql = "FROM Setting WHERE id=?";
		//Setting setting = (Setting) getSession().createQuery(hql).setInteger(0, k).uniqueResult();
		 return (Setting) getSession().get(Setting.class, k);
		//return setting;
	}

	@Override
	public List<Setting> getAll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Setting> getAll(Integer currentIndex, Integer pageSize) {
		// TODO Auto-generated method stub
		return null;
	}

}
